home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
MPW_TOOL
/
TOOLS
/
TOOLS_WI
/
ICON_8
/
COMMON_F
/
LONG.C
< prev
next >
Wrap
Text File
|
1990-03-02
|
786b
|
50 lines
/*
* common.c -- functions common to several modules.
*/
#include "::h:config.h"
#include "::h:cpuconf.h"
#include <ctype.h>
#if IntBits == 16
/*
* Long strlen
*/
long lstrlen(s)
char *s;
{
long l = 0;
while(*s++) l++;
return l;
}
#endif /* IntBits */
/*
* Write a long string in int-sized chunks.
*/
long longwrite(s,len,file)
FILE *file;
char *s;
long len;
{
long tally = 0;
int n = 0;
int leftover, loopnum;
char *p;
leftover = len % MaxInt;
for (p = s, loopnum = len/MaxInt; loopnum; loopnum--) {
n = fwrite(p,sizeof(char),MaxInt,file);
tally += n;
p += MaxInt;
}
if (leftover)
n = fwrite(p,sizeof(char),leftover,file);
tally += n;
if (tally != len)
return -1;
else return tally;
}